package com.sirdc.modules.sys.web.OwnerUnit;

import java.text.ParseException;
import java.util.*;

import javax.servlet.http.HttpServletRequest;

import com.sirdc.modules.sys.filter.NodeNewschedulesModel;
import com.sirdc.modules.sys.service.PlanTimeReckonService;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.Project.entity.LeaderShip;
import net.huashitong.Project.entity.ProIndustryType;
import net.huashitong.Project.service.LeaderShipService;
import net.huashitong.Project.service.ProIndustryTypeService;
import net.huashitong.node.service.NodeSchedulesService;
import net.huashitong.oversee.entity.SupervisionTask;
import net.huashitong.oversee.filter.SupervisionTaskFilter;
import net.huashitong.oversee.service.SupervisionTaskService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.util.WebUtils;

import com.sirdc.modules.sys.service.SysTableService;
import com.sirdc.modules.utils.ObjectUtils;

import net.huashitong.Project.entity.NewProjects;
import net.huashitong.Project.filter.NewProjectsFilter;
import net.huashitong.Project.service.NewProjectsService;
import net.huashitong.Project.util.MessageUtil;
import net.huashitong.node.entity.NodeNewschedules;
import net.huashitong.node.entity.NodeNewtemplet;
import net.huashitong.node.service.NodeNewschedulesService;
import net.huashitong.node.service.NodeNewtempletService;
import net.huashitong.user.entity.BnpUser;
import net.huashitong.user.entity.Message;
import net.huashitong.user.filter.BnpUserFilter;
import net.huashitong.user.service.BnpUserService;
import net.huashitong.user.service.MessageService;

@Controller
@RequestMapping(value = "/onwnerUnit")
public class OwnerManageController {
    Logger logger = LoggerFactory.getLogger("OwnerManageController");
    @Autowired
    private NewProjectsService newProjectsService;
    @Autowired
    private NodeNewtempletService nodeNewtempletService;
    @Autowired
    private NodeNewschedulesService nodeNewschedulesService;
    @Autowired
    private SysTableService tableService;
    @Autowired
    private MessageService ms;
    @Autowired
    private BnpUserService bus;
    @Autowired
    private NodeSchedulesService nodeSchedulesService;
    @Autowired
    private ProIndustryTypeService proIndustryTypeService;
    @Autowired
    private LeaderShipService leaderShipService;
    @Autowired
    private MessageUtil mu;
    @Autowired
    private PlanTimeReckonService planTimeReckonService;
    @Autowired
    private SupervisionTaskService supervisionTaskService;

    @ModelAttribute("headType")
    public String returnHeadType() {
        return "业主模块";
    }

    /**
     * 跳转到项目列表
     *
     * @param request
     * @param model
     * @return
     */
    @RequestMapping(value = "/go/list", method = RequestMethod.GET)
    public String goList(HttpServletRequest request, Model model) {
        BnpUser bu = (BnpUser) WebUtils.getSessionAttribute(request, "user");
        if (ObjectUtils.isBlank(bu)) {
            return "/modules/login/login";
        }
        NewProjectsFilter filter = new NewProjectsFilter();
        if ("经办人".equals(bu.getRole())) {
            filter.setContactPhone(bu.getPhone());
        }
        if ("责任人".equals(bu.getRole())) {
            filter.setOwnerUnitPersonPhone(bu.getPhone());
        }
        List<NewProjects> nplist = newProjectsService.queryByfilter(filter);

        int nodeCount = (int) WebUtils.getSessionAttribute(request, "nodeCount");
        model.addAttribute("nodeCount", nodeCount);
        model.addAttribute("leftType", "我的项目");
        model.addAttribute("nplist", nplist);
        return "/modules/OwnerUnit/owner_task";
    }

    /**
     * 跳转到创建项目界面
     *
     * @param request
     * @param model
     * @return
     */
    @RequestMapping(value = "/go/addProject", method = RequestMethod.GET)
    public String goAddProject(HttpServletRequest request, Model model) {
        BnpUser bu = (BnpUser) WebUtils.getSessionAttribute(request, "user");
        if (ObjectUtils.isBlank(bu)) {
            return "redirect:/newlogin/";
        }
        model.addAttribute("leftType", "我的项目");
        //行业分类
        List<ProIndustryType> industryTypelist = proIndustryTypeService.queryByType("1");
        //项目分类
        List<ProIndustryType> itemTypelist = proIndustryTypeService.queryByType("2");
        //进度分类
        List<ProIndustryType> scheduleTypelist = proIndustryTypeService.queryByType("3");

        model.addAttribute("industryTypelist", industryTypelist);
        model.addAttribute("itemTypelist", itemTypelist);
        model.addAttribute("scheduleTypelist", scheduleTypelist);

        return "/modules/OwnerUnit/createProject";
    }

    /**
     * 创建项目后跳转到项目列表
     *
     * @param request
     * @param model
     * @return
     */
    @RequestMapping(value = "/addProject", method = RequestMethod.POST)
    public String addProject(HttpServletRequest request, Model model, final NewProjectsFilter filter) {
        model.addAttribute("leftType", "我的项目");
        BnpUser bu = (BnpUser) WebUtils.getSessionAttribute(request, "user");
        if (ObjectUtils.isBlank(bu)) {
            return "/modules/login/login";
        }
        LeaderShip leaderShip = leaderShipService.queryByLeaderName(filter.getResUser());
        String natureType1 = filter.getNatureType();

        String natureTypeDetail = "";
        if ("0".equals(natureType1)) {
            natureTypeDetail = "政府投资类";
        }
        if ("1".equals(natureType1)) {
            natureTypeDetail = "企业投资类";
        }
        if ("2".equals(natureType1)) {
            natureTypeDetail = "土地收储类";
        }
        if ("3".equals(natureType1)) {
            natureTypeDetail = "政府投资房建市政类";
        }
        if ("4".equals(natureType1)) {
            natureTypeDetail = "政府投资交通水利类";
        }

        final String operatorUser = filter.getContactName();
        final String operatorPhone = filter.getContactPhone();
        final String resUser = filter.getOwnerUnitPerson();
        final String resUserPhone = filter.getOwnerUnitPersonPhone();

        final NewProjects np = new NewProjects();
        /*-------------------*/
        //责任人
        np.setOwnerUnitPerson(filter.getOwnerUnitPerson());
        //责任人电话
        np.setOwnerUnitPersonPhone(filter.getOwnerUnitPersonPhone());
        //分管领导手机号
        np.setResPhone(leaderShip.getLeaderPhone());
        np.setNatureTypeDetail(natureTypeDetail);
//        np.setPosition();
        /*-------------------*/
        np.setName(filter.getName());                    //项目名称
        np.setResDept(filter.getResDept());                //责任单位
        np.setResUser(filter.getResUser());                //分管领导
        np.setNatureType(filter.getNatureType());        //项目性质类型
        np.setMoney(filter.getMoney());                    //项目金额
        np.setAddress(filter.getAddress());                //项目选址
        np.setDescribes(filter.getDescribes());            //项目描述
        np.setContactName(filter.getContactName());        //联系人（经办人）
        np.setContactPhone(filter.getContactPhone());    //联系电话（经办人电话）
        np.setIndustryType(filter.getIndustryType());    //行业分类
        np.setProjectType(filter.getProjectType());        //项目分类
        np.setSchedCode(filter.getSchedCode());            //进度分类
        np.setUserId(bu.getSysId());                    //用户ID
        np.setStatus("1");                              //进入审核部门确认节点阶段
        np.setOccupyDept(filter.getOccupyDept());//征迁实施单位
        np.setOccupyResUser(filter.getOccupyResUser());//征迁责任人
        np.setOccupyResUserPhone(filter.getOccupyResUserPhone());//征迁责任人电话
        np.setOccupyOperateUser(filter.getOccupyOperateUser());//征迁经办人
        np.setOccupyOperateUserPhone(filter.getOccupyOperateUserPhone());//征迁经办人电话
        np.setPositions(filter.getPositions()); //坐标位置

        newProjectsService.save(np);
        final String projectId = np.getSysId();
        final String natureType = filter.getNatureType();
        final String projectName = np.getName();
        Thread t1 = new Thread() {
            public void run() {
                List<NodeNewschedules> nnsList = new ArrayList<>();
                List<NodeNewtemplet> nntList = nodeNewtempletService.queryNodeNewtempletByNodeType(natureType);
                for (NodeNewtemplet nt : nntList) {
                    NodeNewschedules nns = new NodeNewschedules();
                    nns.setSysId(tableService.updateMaxSysId("t_bnp_node_newschedule", null));
                    nns.setNodeId(nt.getNodeId());
                    nns.setNodeIds(nt.getNodeIds());
                    nns.setPreNodeId(nt.getPreNodeId());
                    nns.setNodeName(nt.getNodeName());
                    nns.setResDept(nt.getResDept());
                    nns.setResUser(StringUtils.isBlank(nt.getResUser()) ? resUser : nt.getResUser());
                    nns.setResUserPhone(StringUtils.isBlank(nt.getResUserPhone()) ? resUserPhone : nt.getResUserPhone());
                    nns.setOperatorUser(StringUtils.isBlank(nt.getOperatorUser()) ? operatorUser : nt.getOperatorUser());
                    nns.setOperatorPhone(StringUtils.isBlank(nt.getOperatorPhone()) ? operatorPhone : nt.getOperatorPhone());
                    nns.setType(nt.getType());
                    nns.setNodeType(nt.getNodeType());
                    nns.setPlanTime(nt.getPlanTime());
                    nns.setFactTime("0");
                    nns.setFactFinishDate(nt.getFactFinishDate());
                    nns.setPlanBeginDate(nt.getPlanBeginDate());
                    nns.setStatus(nt.getStatus());
                    nns.setState(nt.getState());
                    nns.setIsDelay("0");
                    nns.setProjectId(projectId);
                    if ("5.3".equals(nt.getNodeId()) || "23.1".equals(nt.getNodeId())) {
                        nns.setResUser(filter.getOccupyResUser());
                        nns.setOperatorUser(filter.getOccupyOperateUser());
                    }
                    nnsList.add(nns);
                    //发送给审批部门审核
                    if (!nns.getResDept().contains("中介")
                            && !nns.getResDept().contains("业主")
                            && ObjectUtils.isNotBlank(nns.getOperatorUser())
                            && ObjectUtils.isNotBlank(nns.getOperatorPhone())
                            && "1".equals(nns.getType())) {
                        Map<String, Object> ma = mu.confirmTaskMessage(
                                nns.getOperatorUser(),
                                nns.getOperatorPhone(),
                                "《" + projectName + "》",
                                nns.getNodeId());
                        if ("0".equals(ma.get("code").toString())) {
                            Message m = new Message();
                            m.setRecipients(nns.getOperatorUser());
                            m.setText(ma.get("text").toString());
                            m.setType("0");
                            m.setPhone(nns.getOperatorPhone());
                            m.setMsg(ma.get("msg").toString());
                            System.out.println(ma.get("msg").toString());
                            m.setProjectName(projectName);
                            m.setResDept(nns.getResDept());
                            m.setNodeId(nns.getSysId());
                            ms.save(m);
                        }
                    }
                }
                nodeNewschedulesService.batchSaveObject(nnsList);
            }
        };
        t1.start();
        return "redirect:/myProjects";
    }

    /**
     * 去配置节点信息
     *
     * @param request
     * @param model
     * @param filter
     * @return
     */
    @RequestMapping(value = "/go/configNode", method = RequestMethod.GET)
    public String goConfigNode(HttpServletRequest request, Model model, NewProjectsFilter filter) {
        model.addAttribute("leftType", "我的项目");
        NewProjects mP = newProjectsService.getById(filter.getSysId());
        model.addAttribute("newProjects", mP);
        List<Map<String, Object>> List1 = new ArrayList<>();
        List<NodeNewschedules> list1 = nodeNewschedulesService.queryListByProjectId(filter.getSysId(), "1", "", "", "");
        List<NodeNewschedules> listd2 = nodeNewschedulesService.queryListByProjectId(filter.getSysId(), "1", "", "", "");
        for (NodeNewschedules nns : list1) {
            if ("1".equals(nns.getType())) {
                List<NodeNewschedules> List2 = new ArrayList<>();
                Map<String, Object> map1 = new HashMap<>();
                map1.put("sysId", nns.getSysId());
                map1.put("nodeId", nns.getNodeId());
                map1.put("preNodeId", nns.getPreNodeId());
                map1.put("nodeName", nns.getNodeName());
                map1.put("resDept", nns.getResDept());
                map1.put("resUser", nns.getResUser());
                map1.put("nodeType", nns.getNodeType());
                map1.put("status", nns.getStatus());
                for (NodeNewschedules nns2 : listd2) {
                    if (nns.getNodeId().equals(nns2.getNodeIds()) && !"2".equals(nns2.getState())) {
                        List2.add(nns2);
                    }
                }
                map1.put("childNodesList", List2);
                List1.add(map1);
            }
        }
        BnpUserFilter filters = new BnpUserFilter();
        filters.setRole("责任人");
        BnpUser bu = (BnpUser) WebUtils.getSessionAttribute(request, "user");
        if (ObjectUtils.isBlank(bu)) {
            return "/modules/login/login";
        }
        filters.setBranch(bu.getBranch());
        List<BnpUser> dutyList = bus.getUserInfo(filters);
        filters.setRole("经办人");
        List<BnpUser> handleList = bus.getUserInfo(filters);
        model.addAttribute("dutyList", dutyList);
        model.addAttribute("handleList", handleList);
        model.addAttribute("nodesList", List1);
        return "/modules/OwnerUnit/configNode";
    }

    /**
     * 小节点确定操作
     *
     * @param request
     * @param model
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/configNode", method = RequestMethod.POST)
    public Object configNode(HttpServletRequest request, Model model) {
        Map<String, Object> map = new HashMap<String, Object>();
        String projectId = request.getParameter("projectId");
        String resUser = request.getParameter("resUser");
        String operatorUser = request.getParameter("operatorUser");
        String planTime = request.getParameter("planTime");
        String nodeId = request.getParameter("nodeId");
        NodeNewschedules ns = nodeNewschedulesService.getNodeNewschedulesByProjectIdAndNodeId(projectId, nodeId);
        BnpUser rUser = bus.getById(resUser);
        BnpUser oUser = bus.getById(operatorUser);
        ns.setPlanTime(planTime);
        ns.setResUser(rUser.getName());
        ns.setResUserPhone(rUser.getPhone());
        ns.setOperatorPhone(oUser.getPhone());
        ns.setOperatorUser(oUser.getName());
        ns.setState("1");
        nodeNewschedulesService.update(ns);
        List<NodeNewschedules> list = nodeNewschedulesService.getNodePlanTime(projectId, "0");
        if (list.size() == 0) {
            NewProjects np = newProjectsService.getById(projectId);
            np.setStatus("2");
            newProjectsService.update(np);
        }
        map.put("msp", "提交成功！");
        map.put("status", true);
        return map;
    }

    /**
     * 查看项目节点信息
     *
     * @param filter
     * @param model
     * @return
     */
    @RequestMapping(value = "/queryNode")
    public String queryNodeByProjectId(@ModelAttribute NewProjectsFilter filter, Model model, @RequestParam String sysId) throws ParseException {
        model.addAttribute("leftType", "我的项目");
        List<NodeNewschedulesModel> models = new ArrayList<>();
        filter.setSysId(sysId);
        NewProjects projectList = newProjectsService.getProjectInfo(filter).get(0);
        // state:2 == 不需要(Dao层条件是'!=')
        List<NodeNewschedules> nodeList = nodeNewschedulesService.getNodeByProjectIdAndState(filter.getSysId(), "");


        SupervisionTaskFilter taskFilter = new SupervisionTaskFilter();
        taskFilter.setProjectId(sysId);
        List<SupervisionTask> tasks = supervisionTaskService.getTaskListsNoPage(taskFilter);
        Map<String, SupervisionTask> nodeTaskMap = new HashMap<>();
        for (SupervisionTask t : tasks) {
            if (!nodeTaskMap.containsKey(t.getNodeId())) {
                nodeTaskMap.put(t.getNodeId(), t);
            }
        }

        int supervisionCount = 0;
        if (ObjectUtils.isNotBlank(tasks) && tasks.size() > 0) {
            for (int i = 0; i < tasks.size(); i++) {
                supervisionCount = supervisionCount +
                        Integer.parseInt(StringUtils.isBlank(tasks.get(i).getTasktimes()) ?
                                "1" : tasks.get(i).getTasktimes());
            }
        }

        //各个节点的前置节点
        Map<String, Object> preOfNodeMap = nodeNewschedulesService.getEachNodePro(nodeList, projectList);

        for (NodeNewschedules n : nodeList) {
            NodeNewschedulesModel m = new NodeNewschedulesModel();
            //对象复制n->m
            BeanUtils.copyProperties(n, m);
            models.add(m);
        }
        //推算计划时间
        models = planTimeReckonService.reckonPlanTime(models, preOfNodeMap);
        //批量更新时间状态
//        nodeNewschedulesService.batchUpdateObject(nodeList);
        model.addAttribute("projectList", projectList);

        List<NodeNewschedulesModel> bigNodeModel = new ArrayList<>();       //大节点
        List<NodeNewschedulesModel> smallNodeModel = new ArrayList<>();     //小节点
        List<NodeNewschedulesModel> noUseNodeModel = new ArrayList<>();     //无用节点
        List<NodeNewschedulesModel> resultNodeModel = new ArrayList<>();     //无用节点

        int factUseTime = 0;    //实际用时
        int planUseTime = 0;    //计划用时

        int factUseTimeAll = 0;    //所有实际用时
        int planUseTimeAll = 0;    //所有计划用时

        StringBuffer strBufFinish = new StringBuffer();
        StringBuffer strBufNoFinish = new StringBuffer();
        StringBuffer strBufBegin = new StringBuffer();

        String planTimeInBegin = "0";    //进行中节点计划用时

        int noFinishNodeNum = 0;         //未完成节点个数
        int doingNodeNum = 0;            //进行中节点个数
        int finishedNodeNum = 0;         //已完成节点个数

        for (NodeNewschedulesModel m : models) {
            if ("1".equals(m.getState()) && "1".equals(m.getType())) {
                //确定的大节点
                if (StringUtils.isBlank(m.getPlanBeginDate()) && StringUtils.isBlank(m.getPlanBeginTime())) {
//                    noUseNodeModel.add(m);
//                    continue;
                }
                bigNodeModel.add(m);
                if ("2".equals(m.getStatus())) {
                    strBufFinish.append(m.getNodeId() + ";");
                    factUseTime = factUseTime + Integer.parseInt(StringUtils.isBlank(m.getFactTime()) ? "0" : m.getFactTime());
                    finishedNodeNum++;
                } else {
                    strBufNoFinish.append(m.getNodeId() + ";");
                    planUseTime = planUseTime + Integer.parseInt(StringUtils.isBlank(m.getPlanTime()) ? "0" : m.getPlanTime());
                    noFinishNodeNum++;
                }
                factUseTimeAll = factUseTimeAll + Integer.parseInt(StringUtils.isBlank(m.getFactTime()) ? "0" : m.getFactTime());
                planUseTimeAll = planUseTimeAll + Integer.parseInt(StringUtils.isBlank(m.getPlanTime()) ? "0" : m.getPlanTime());

            } else if ("1".equals(m.getState()) && "2".equals(m.getType())) {
                //确定的小节点
                if (StringUtils.isBlank(m.getPlanBeginDate()) && StringUtils.isBlank(m.getPlanBeginTime())) {
//                    noUseNodeModel.add(m);
//                    continue;
                }
                if ("1".equals(m.getStatus())) {
                    strBufBegin.append(m.getNodeId() + ";");
                    planTimeInBegin = m.getPlanTime();
                    doingNodeNum++;
                }
                smallNodeModel.add(m);
            } else {
                noUseNodeModel.add(m);
            }
        }

        //排序实际开始时间正序排，如果没有实际开始时间则取计划开始时间
        Collections.sort(bigNodeModel, new Comparator<NodeNewschedulesModel>() {
            @Override
            public int compare(NodeNewschedulesModel m1, NodeNewschedulesModel m2) {
                String factBegin1 = m1.getPlanBeginDate();//实际开始时间
                if (StringUtils.isBlank(factBegin1)) {
                    if (StringUtils.isBlank(m1.getPlanBeginTime())) {
                        return 1;
                    }
                    factBegin1 = m1.getPlanBeginTime();//计划开始时间
                }
                long longFactBegin1 = Long.valueOf(factBegin1.replace(".", ""));

                String factBegin2 = m2.getPlanBeginDate();//实际开始时间
                if (StringUtils.isBlank(factBegin2)) {
                    if (StringUtils.isBlank(m2.getPlanBeginTime())) {
                        return 1;
                    }
                    factBegin2 = m2.getPlanBeginTime();//计划开始时间
                }
                long longFactBegin2 = Long.valueOf(factBegin2.replace(".", ""));

                if (longFactBegin1 < longFactBegin2) {
                    return -1;
                } else if (longFactBegin1 == longFactBegin2) {
                    return 0;
                } else {
                    return 1;
                }
            }
        });

        for (NodeNewschedulesModel big : bigNodeModel) {
            resultNodeModel.add(big);
            for (NodeNewschedulesModel small : smallNodeModel) {
                if (big.getNodeId().equals(small.getNodeIds())) {
                    resultNodeModel.add(small);
                }
            }
        }
        resultNodeModel.addAll(noUseNodeModel);

        //督查节点（小节点）
        List<NodeNewschedulesModel> smallSupervisionNodes = new ArrayList<>();
        for (NodeNewschedulesModel m : resultNodeModel) {
            if (nodeTaskMap.containsKey(m.getNodeId())) {
                m.setTaskId(nodeTaskMap.get(m.getNodeId()).getSysId());
                m.setTaskTimes(nodeTaskMap.get(m.getNodeId()).getTasktimes());
                smallSupervisionNodes.add(m);
            }
        }


        //节点最终结果
        List<NodeNewschedulesModel> resultNodes = new ArrayList<>();
        Map<String, NodeNewschedulesModel> resultBigMaps = new HashMap<>();

        if (StringUtils.isNotBlank(filter.getSupervisionFlag())) {
            if ("true".equals(filter.getSupervisionFlag())) {
                //查看督查节点
                for (NodeNewschedulesModel node : resultNodeModel) {
                    if ("1".equals(node.getType())) {
                        //大节点
                        if (!resultBigMaps.containsKey(node.getNodeId())) {
                            resultBigMaps.put(node.getNodeId(), node);
                        }
                    }
                }
                for (NodeNewschedulesModel m : smallSupervisionNodes) {
                    String bigNode = m.getNodeIds();
                    if (resultBigMaps.containsKey(bigNode)) {
                        NodeNewschedulesModel big = resultBigMaps.get(bigNode);
                        if (!resultNodes.contains(big)) {
                            resultNodes.add(big);
                            resultNodes.add(m);
                        } else {
                            resultNodes.add(m);
                        }
                    }
                }
            } else {
                resultNodes.addAll(resultNodeModel);
            }
        } else {
            resultNodes.addAll(resultNodeModel);
        }

        StringBuffer stringBuffer = new StringBuffer();
        if (smallSupervisionNodes.size() > 0) {
            for (int i = 0; i < smallSupervisionNodes.size(); i++) {
                if (i == 0) {
                    stringBuffer.append(smallSupervisionNodes.get(i).getNodeId());
                } else {
                    stringBuffer.append("、" + smallSupervisionNodes.get(i).getNodeId());
                }
            }
            model.addAttribute("taskNodes", stringBuffer.toString());
        } else {
            model.addAttribute("taskNodes", "");
        }

        model.addAttribute("nodeList", resultNodes);

        model.addAttribute("factUseTime", factUseTime);
        model.addAttribute("strBufFinish", strBufFinish.toString());
        model.addAttribute("planUseTime", planUseTime);
        model.addAttribute("strBufNoFinish", strBufNoFinish.toString());

        //所有节点
        model.addAttribute("factUseTimeAll", factUseTimeAll);
        model.addAttribute("planUseTimeAll", planUseTimeAll);

        //进行中的节点
        model.addAttribute("planTimeInBegin", planTimeInBegin);
        model.addAttribute("strBufBegin", strBufBegin.toString());

        //sysId
        model.addAttribute("sysId", sysId);
        //总共督查的次数
        model.addAttribute("supervisionCount", supervisionCount + "");

        model.addAttribute("noFinishNodeNum", noFinishNodeNum + "");  //未完成节点个数
        model.addAttribute("doingNodeNum", doingNodeNum + "");        //进行中节点个数
        model.addAttribute("finishedNodeNum", finishedNodeNum + "");  //已完成节点个数

        return "/modules/OwnerUnit/projectInfo";
    }



    @ResponseBody
    @RequestMapping(value = "/verifyLeaderExist", method = RequestMethod.GET)
    public Map<String, Object> verifyLeaderExist(String leaderName) {
        boolean flag = leaderShipService.getLeaderExist(leaderName);
        Map<String, Object> resMap = new HashMap<>();
        resMap.put("exist", flag);
        return resMap;
    }

}
